package com.commun;

import java.util.HashMap;
import java.util.Map;

import maps.test.R;
import android.content.Context;
import android.media.*;

public class MyMediaPlayer {
	private Map<TypeSounde, Integer> mSoundsMap;
	private AudioManager mAudioManager;
	MediaPlayer myMediaPlayer;
	private Context mContext;

	public static enum TypeSounde {
		ZOOM_IN, ZOOM_OUT, TAP
	}

	public void initSounds(Context theContext) {
		mContext = theContext;
		mSoundsMap = addSounds();

		mAudioManager = (AudioManager) mContext
				.getSystemService(Context.AUDIO_SERVICE);
	}

	public Map<TypeSounde, Integer> addSounds() {
		Map<TypeSounde, Integer> mSoundsMap = new HashMap<TypeSounde, Integer>();
		mSoundsMap.put(TypeSounde.ZOOM_IN, R.raw.zoom);

		return mSoundsMap;
	}

	public Context getmContext() {
		return mContext;
	}

	public void setmContext(Context mContext) {
		this.mContext = mContext;
	}

	public void playSound(TypeSounde name) {
		float streamVolume = mAudioManager
				.getStreamVolume(AudioManager.STREAM_MUSIC);
		streamVolume = streamVolume
				/ mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
		myMediaPlayer = MediaPlayer.create(getmContext(),
				Integer.parseInt(mSoundsMap.get(name).toString()));
		myMediaPlayer.start();
	}

}
